package com.lry.event;


import com.lry.proxy.Invoker;
import com.lry.proxy.RpcInvoker;
import com.lry.rpc.netty.BeanKey;
import com.lry.rpc.netty.client.ChannelWrapper;
import com.lry.rpc.netty.client.ClientCache;

import java.util.List;

import static com.lry.common.CommonConstants.COLON;

public class NodeChangeListener implements RpcListener<NodeChangeEvent>{

    @Override
    public boolean callback(NodeChangeEvent nodeChangeEvent) {
        ProviderNodeWrapper providerNodeWrapper = nodeChangeEvent.getProviderNodeWrapper();

        BeanKey beanKey = new BeanKey(providerNodeWrapper.getServiceName(),providerNodeWrapper.getImplName(),providerNodeWrapper.getVersion());

        Invoker invoker = ClientCache.getInvoker(beanKey ,providerNodeWrapper.getGroup(),providerNodeWrapper.getIp());

        invoker.updateWeight(providerNodeWrapper.getWeight());

        return true;
    }
}
